// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2024 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.7
package sys

import (
	"context"
	"hotgo/addons/hgexample/api/admin/epcategory"
	"hotgo/addons/hgexample/model/input/sysin"
	"hotgo/addons/hgexample/service"
)

var (
	EpCategory = cEpCategory{}
)

type cEpCategory struct{}

// List 查看物品分类列表
func (c *cEpCategory) List(ctx context.Context, req *epcategory.ListReq) (res *epcategory.ListRes, err error) {
	list, totalCount, err := service.SysEpCategory().List(ctx, &req.EpCategoryListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.EpCategoryListModel{}
	}

	res = new(epcategory.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Edit 更新物品分类
func (c *cEpCategory) Edit(ctx context.Context, req *epcategory.EditReq) (res *epcategory.EditRes, err error) {
	err = service.SysEpCategory().Edit(ctx, &req.EpCategoryEditInp)
	return
}

// View 获取指定物品分类信息
func (c *cEpCategory) View(ctx context.Context, req *epcategory.ViewReq) (res *epcategory.ViewRes, err error) {
	data, err := service.SysEpCategory().View(ctx, &req.EpCategoryViewInp)
	if err != nil {
		return
	}

	res = new(epcategory.ViewRes)
	res.EpCategoryViewModel = data
	return
}

// Delete 删除物品分类
func (c *cEpCategory) Delete(ctx context.Context, req *epcategory.DeleteReq) (res *epcategory.DeleteRes, err error) {
	err = service.SysEpCategory().Delete(ctx, &req.EpCategoryDeleteInp)
	return
}